package com.example.jikeyoujikeyou.office_sz.view.activity.register.subActivity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.example.jikeyoujikeyou.office_sz.R;
import com.example.jikeyoujikeyou.office_sz.view.TitleBar;
import com.example.jikeyoujikeyou.office_sz.view.base.BaseActivity;

public class EditDepartmentActivity extends BaseActivity {

    private TitleBar titleBar;
    private TextView et_enterprise_department;

    private static final int SUCCESS = 500;
    private static final int FAILURE = 0;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_enterprise_department);
        init();
    }

    private void init() {
        setTitle("注册账户");
        titleBar = getTitleBar();
        titleBar.getIv_return().setVisibility(View.GONE);
        titleBar.getTv_cancel().setVisibility(View.VISIBLE);
        titleBar.getTv_setting().setVisibility(View.VISIBLE);

        titleBar.getTv_cancel().setText("取消");
        titleBar.getTv_setting().setText("保存");

        et_enterprise_department = (TextView) findViewById(R.id.et_enterprise_department);

        titleBar.getTv_cancel().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                setResult(FAILURE, new Intent());
                finish();
            }
        });

        titleBar.getTv_setting().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String department_name =  et_enterprise_department.getText().toString();
                Intent intent =  new Intent();
                intent.putExtra("department_name",department_name);
                if (department_name == null || department_name.trim().equals("")) {
                    setResult(FAILURE,intent);
                } else {
                    setResult(SUCCESS,intent);
                }
                finish();
            }
        });
    }


    private void setTitle(String title){
        getTitleBar().getTv_title().setText(title);
    }

}
